package com.tsing.common.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@Component
@PropertySource("classpath:shiroConfig.properties")
@ConfigurationProperties(prefix = "shiro")
public class ShiroConfigProp {

    private String loginUrl;
    private String successUrl;
    private List<String> filterChainDefinitionList = new ArrayList<String>();

    public Map<String, String> getfilterChainDefinitionMap() {
        Map<String, String> result = new LinkedHashMap<String, String>();
        filterChainDefinitionList.forEach(item -> {
            result.put(item.split("=")[0], item.split("=")[1]);
        });
        return result;
    }

    public String getLoginUrl() {
        return loginUrl;
    }

    public void setLoginUrl(String loginUrl) {
        this.loginUrl = loginUrl;
    }

    public String getSuccessUrl() {
        return successUrl;
    }

    public void setSuccessUrl(String successUrl) {
        this.successUrl = successUrl;
    }

    public List<String> getFilterChainDefinitionList() {
        return filterChainDefinitionList;
    }

    public void setFilterChainDefinitionList(List<String> filterChainDefinitionList) {
        this.filterChainDefinitionList = filterChainDefinitionList;
    }

}
